<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('会员管理列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <!--                            <li>-->
                        <!--                                <label>会员编号：</label>-->
                        <!--                                <input type="text" name="id"/>-->
                        <!--                            </li>-->
                        <li>
                            <label>会员姓名：</label>
                            <input type="text" name="name"/>
                        </li>
                        <li>
                            <label>手机号码：</label>
                            <input type="text" name="phone"/>
                        </li>
                        <!--                            <li>-->
                        <!--                                <label>电子邮箱：</label>-->
                        <!--                                <input type="text" name="email"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <label>账户余额：</label>-->
                        <!--                                <input type="text" name="balance"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <label>总消费：</label>-->
                        <!--                                <input type="text" name="totalConsumption"/>-->
                        <!--                            </li>-->
                        <li>
                            <label>注册时间：</label>
                            <input type="text" class="time-input" placeholder="请选择注册时间" name="createTime"/>
                        </li>
                        <!--                            <li>-->
                        <!--                                <label>积分：</label>-->
                        <!--                                <input type="text" name="points"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <label>最后消费时间：</label>-->
                        <!--                                <input type="text" class="time-input" placeholder="请选择最后消费时间" name="lastConsumeTime"/>-->
                        <!--                            </li>-->
                        <!--                            <li>-->
                        <!--                                <label>会员等级：</label>-->
                        <!--                                <input type="text" name="level"/>-->
                        <!--                            </li>-->
                        <li>
                            <label>折扣比例：</label>
                            <input type="text" name="discountRatio"/>
                        </li>
                        <li>
                            <label>会员生日：</label>
                            <input type="text" class="time-input" placeholder="请选择会员生日" name="birthdate"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--                <a class="btn btn-info single disabled" onclick="edit2()" shiro:hasPermission="business:member:add">-->
            <!--                    <i class="fa fa-plus "></i> 充值-->
            <!--                </a>-->
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="business:member:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="business:member:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="business:member:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="business:member:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('business:member:edit')}]];
    var removeFlag = [[${@permission.hasPermi('business:member:remove')}]];
    var prefix = ctx + "business/member";


    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            rechargeUrl: prefix + "/recharge/{id}",
            modalName: "会员管理",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '会员编号',
                    //visible: false
                },
                {
                    field: 'name',
                    title: '会员姓名'
                },
                {
                    field: 'phone',
                    title: '手机号码'
                },
                {
                    field: 'email',
                    title: '电子邮箱'
                },
                {
                    field: 'balance',
                    title: '账户余额'
                },
                {
                    field: 'totalConsumption',
                    title: '总消费'
                },
                // {
                //     field: 'points',
                //     title: '积分'
                // },
                {
                    field: 'lastConsumeTime',
                    title: '最后消费时间'
                },
                // {
                //     field: 'level',
                //     title: '会员等级'
                // },
                {
                    field: 'discountRatio',
                    title: '目前折扣比例'
                },
                {
                    field: 'birthdate',
                    title: '会员生日'
                },
                {
                    field: 'createTime',
                    title: '注册时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    width: 250,
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-info btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="recharge(\'' + row.id + '\')"><i class="fa fa-edit"></i>充值</a> ');
                        actions.push('<a class="btn btn-default btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="consume(\'' + row.id + '\')"><i class="fa fa-edit"></i>消费</a> ');

                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };

        $.table.init(options);


    });

    let recharge = function (id) {
        $.modal.open("充值", prefix + "/recharge/" + id, undefined, 300);
    }
    //
    let consume = function (id) {
        $.modal.open("消费", prefix + "/consume/" + id, undefined, 300);
    }


</script>
</body>
</html>